package day1105.first;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static day1105.common.MyUtil.printLine;

/**
 * @author Mr.ma
 * @since 2022/11/5 16:08
 * concat(): Stream中的静态方法，需要两个stream流作为参数，用于两个的合并
 **/
public class ConcatTest {
    public static void main(String[] args) {
        printLine("将字符串数组拆分为字符后，进行合并，然后去重");
        String[] arr = new String[]{"hello","world"};
        List<String[]> collect = Arrays.stream(arr).map(x -> x.split("")).collect(Collectors.toList());
        System.out.println("collect = " + collect);
        List<String> collect1 = Stream.concat(Arrays.stream(collect.get(0)), Arrays.stream(collect.get(1))).distinct().collect(Collectors.toList());
        System.out.println("collect1 = " + collect1);
    }
}
